var zhRunning = "正在运行"
var zhInfo = "信息"

function extractor(query) {
    var result = /([^\n]+)$/.exec(query);
    if (result && result[1])
        return result[1].trim();
    return '';
}

var matcherRegex = /[^\n]*$/
var matcherEnd = "\n"
var num = 3

function proteinIDFmt(value, row, index) {
    return "<a onclick=\"showExp('" + value + "')\">" + value + "</a>"
}

function metaboliteIDFmt(value, row, index) {
    return "<a onclick=\"showMExp('" + value + "')\">" + value + "</a>"
}

function showMExp(value) {
    var html = "\t<div id='exp'><div id=\"addRelation\" class=\"modal fade\" tabindex=\"-1\" role=\"dialog\" aria-labelledby=\"myModalLabel\" aria-hidden=\"true\">\n" +
        "\t\t\t\t\t\t\t\t\t<div class=\"modal-dialog\" style=\"width: 1070px\">\n" +
        "\t\t\t\t\t\t\t\t\t\t<div class=\"modal-content\">\n" +
        "\t\t\t\t\t\t\t\t\t\t\t<div class=\"modal-header bg-primary\">\n" +
        "\t\t\t\t\t\t\t\t\t\t\t\t<button type=\"button\" class=\"close\" data-dismiss=\"modal\" aria-hidden=\"true\"></button>\n" +
        "\t\t\t\t\t\t\t\t\t\t\t\t<h4 class=\"modal-title\">\n" +
        "\t\t\t\t\t\t\t\t\t\t\t\t\t<span id=\"lblAddTitle\" style=\"font-weight: bold\">表达信息柱状图</span>\n" +
        "\t\t\t\t\t\t\t\t\t\t\t\t</h4>\n" +
        "\t\t\t\t\t\t\t\t\t\t\t</div>\n" +
        "\t\t\t\t\t\t\t\t\t\t\t\t<div class=\"modal-body\">\n" +
        "\t\t\t\t\t\t\t\t\t\t\t\t\t\t<div id=\"expCharts\"  style=\"width: 100%\">\n" +
        "\n" +
        "\t\t\t\t\t\t\t\t\t\t\t\t\t\t\t</div>\n" +
        "\t\t\t\t\t\t\t\t\t\t\t\t</div>\n" +
        "\t\t\t\t\t\t\t\t\t\t</div>\n" +
        "\t\t\t\t\t\t\t\t\t</div>\n" +
        "\t\t\t\t\t\t\t\t</div></div>"
    var expHtml = $("#exp").html()
    if (typeof(expHtml) === "undefined") {
        $("body").append(html)
    }

    var index = layer.load(0, {shade: false})
    $.ajax({
        url: "/platform/user/metabolite/plotExp",
        type: "post",
        data: {
            geneId: value
        },
        success: function (data) {
            layer.close(index)
            if (data.valid == "false") {
                $("#charts").html("没有图片结果生成！")
                swal("Error", data.message, "error")
            } else {
                $("#expCharts").html(data.div)
                $("#addRelation").modal("show")
            }
        }
    });
}



$(function () {

    $("[data-toggle='popover']").popover()

})
